package com.chengdu.his.utils;

public class CommonResult<T> {
    private int code;       // Status code (e.g., 200, 404, 500)
    private String message; // Descriptive message (e.g., "Success", "Not Found")
    private T data;        // The actual data payload (generic type)

    // Constructors
    public CommonResult() {}
    
    public CommonResult(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    // Getters and Setters
    public int getCode() { return code; }
    public void setCode(int code) { this.code = code; }
    
    public String getMessage() { return message; }
    public void setMessage(String message) { this.message = message; }
    
    public T getData() { return data; }
    public void setData(T data) { this.data = data; }

    // Helper method for success
    public static <T> CommonResult<T> success(T data) {
        return new CommonResult<>(200, "Success", data);
    }

    // Helper method for error
    public static <T> CommonResult<T> error(int code, String message) {
        return new CommonResult<>(code, message, null);
    }
}